# 统计颜色多少种
# import pandas as pd
# df = pd.read_csv('raw-data.txt', sep='\t', header=0)
# color_df = df['颜色'].value_counts();
# color_df.to_csv('color.csv',sep='\t');

# 绘制颜色分布饼图
# import pandas as pd
# labels = []
# values = []
# df = pd.read_csv('color.csv', sep='\t', header=None)
# labels = df[0]
# values = df[1]
# import matplotlib.pyplot as plt
# fig = plt.figure()
# plt.pie(values,labels=labels,autopct='%1.2f%%')
# plt.title("颜色分布图")
# plt.show()

# 统计材质多少种
# import pandas as pd
# df = pd.read_csv('raw-data.txt', sep='\t', header=0)
# color_df = df['材质'].value_counts();
# color_df.to_csv('material.csv',sep='\t');

# 绘制材质分布饼图
import pandas as pd
labels = []
values = []
df = pd.read_csv('material.csv', sep='\t', header=None)
labels = df[0]
values = df[1]
import matplotlib.pyplot as plt
fig = plt.figure()
patches,l_text,p_text = plt.pie(values,labels=labels,autopct='%1.2f%%')
# 设置饼图内文字大小
for t in p_text:
    t.set_size(6)
for t in l_text:
    t.set_size(9)
plt.title("材质分布图")
plt.show()